<?php include('header.php')	?>

<?php
	$status = $_REQUEST['status'];
	if($status != '')
		$MyPlurk->PostPlurk($status);
?>

<?php
	if($_REQUEST['user_id'] == '') {	
		$data = $MyPlurk->GetOwnProfile();
	} else {
		$data = $MyPlurk->GetPublicProfile($_REQUEST['user_id']);
		$profile_view = true;
		$profile_id = $_REQUEST['user_id'];
	}

	$avatar = $MyPlurk->GetAvatar($data['user_info']['uid'], $data['user_info']['avatar'], 'medium');
	$my_uid = $data['user_info']['uid'];
	
	print "<div class='user_info'>";
	
	print "<div style='float:left;'>";
	print "<img src='".$avatar."' />";
	print "</div>";

	print "<div style='float:left; margin-left:10px;'>";	
	if($profile_view == false) {
		print "Welcome, ";
	}
	print "<strong>".$data['user_info']['full_name']."</strong> (@".$data['user_info']['nick_name'].")<br />";	
	print "Friends: ".$data['friends_count']."<br />";
	print "Fans: ".$data['fans_count']."<br />";
	print "Karma: ".$data['user_info']['karma'];	
	print "</div>";

	print "<div style='clear:both'></div>";	
	print "</div>";	

	
	if($_REQUEST['mode'] == '') {
		//print "<h2>Timeline</h2>";
		if($profile_view == false) {
			include('form_status.php');
			$offset = trim($_REQUEST['offset']);
			$data = $MyPlurk->GetPlurks(false, $offset);
		} else {
			//print $profile_id;
			$data = $MyPlurk->GetPlurks(false,'',$profile_id);
		}				
	} else if($_REQUEST['mode'] == 'unread') {
		print "<h2>Unread Plurks</h2>";	
		$data = $MyPlurk->GetUnreadPlurks();
	} else if($_REQUEST['mode'] == 'responded') {
		print "<h2>Responded Plurks</h2>";	
		$data = $MyPlurk->GetPlurks(true);
	}
	
	foreach ($data['plurks'] as $plurk) {
		$owner_id = $plurk['owner_id'];
		$avatar = $MyPlurk->GetAvatar($owner_id, $data['plurk_users'][$owner_id]['avatar']);
		$display_name = $data['plurk_users'][$owner_id]['display_name'];
		if($plurk['qualifier_translated'] != '') {
			$qualifier = $plurk['qualifier_translated'];
		} else {
			$qualifier = $plurk['qualifier'];
		}
		
		if($plurk['is_unread'] != 0) {
			$response_counter = '<strong>('.$plurk['response_count'].' respon)</strong>';
		} else {
			$response_counter = '('.$plurk['response_count'].' respon)';
		}		
		
		if($plurk['owner_id'] == $my_uid)
			$author_class = 'plurk-response_by_me';
					
		$content = '<span class="qualifier">'.$qualifier.'</span>'.$plurk['content'];
		$plurkID = $plurk['plurk_id'];
		print "<div class='plurk ".$author_class."'><img src='".$avatar."' class='plurk_avatar' /> <a href='index.php?user_id=".$owner_id."'><strong>".$display_name."</strong></a>".$content." <a href='get_responses.php?plurkID=".$plurkID."'>".$response_counter."</a></div>";
		$author_class = ''; // reset
		
		$last_plurk = $plurk['posted'];
		$last_plurk = strtotime($last_plurk);
		$last_plurk = date('c',$last_plurk);
		$last_plurk = substr($last_plurk,0,-6);		
	}
?>
<center><a href="index.php?offset=<?php print $last_plurk ?>">Next</a></center>
<?php include('footer.php') ?>